package cn.tedu.csmall.product.controller;

import cn.tedu.csmall.product.pojo.dto.AlbumAddNewDTO;
import cn.tedu.csmall.product.pojo.dto.BrandCategoryAddNewDTO;
import cn.tedu.csmall.product.pojo.vo.AlbumListItemVO;
import cn.tedu.csmall.product.service.IAlbumService;
import cn.tedu.csmall.product.service.IBrandCategoryService;
import cn.tedu.csmall.product.web.JsonResult;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.hibernate.validator.constraints.Range;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * 处理品牌与类别关联相关请求的控制器
 *
 * @author java@tedu.cn
 * @version 0.0.1
 */
@Api(tags = "06品牌与类别关联管理模块")
@Validated//新添加的注解
@Slf4j
@RestController
@RequestMapping("/brand-category")
public class BrandCategoryController {

    @Autowired
    private IBrandCategoryService iBrandCategoryService;

    public BrandCategoryController() {
        log.debug("创建控制器对象：BrandCategoryControlle");
    }

    @ApiOperation("品牌与类别关联")
    @ApiOperationSupport(order = 100)
    @PostMapping("/add-new")
    public JsonResult<Void> addNew(@Valid BrandCategoryAddNewDTO brandCategoryAddNewDTO) {
        log.debug("开始处理【添加】的请求，参数：{}", brandCategoryAddNewDTO);
        iBrandCategoryService.addNew(brandCategoryAddNewDTO);
        log.debug("添加品牌与类别关联成功！");
        return JsonResult.ok();
    }

    @ApiOperation("解除品牌与类别关联")
    @ApiOperationSupport(order = 200)
    @PostMapping("{brandId:[0-9]+}/{categoryId:[0-9]+}/delete")
    public JsonResult<Void> delete(@PathVariable Long brandId, @PathVariable Long categoryId) {
        log.debug("开始处理【添加】的请求，参数：{},{}", brandId,categoryId);
        iBrandCategoryService.delete(brandId,categoryId);
        log.debug("删除成功");
        return JsonResult.ok();
    }


}
